import pymongo

myclient = pymongo.MongoClient('mongodb://localhost:27017/')

mydict = {"name": "RUNOOB", "alexa": "10000", "url": "https://www.runoob.com"}

mydb = myclient['zhouheng']

mycol = mydb["sites"]

x = mycol.insert_one(mydict)
print(x)

mydict = {"name": "Google", "alexa": "1", "url": "https://www.google.com"}
x = mycol.insert_one(mydict)
# 插入后打印ID
print(x.inserted_id)

